#ifndef MyStack_H
#define MyStack_H
template<typename Object>
class MyStack{
private:
	int theSize;
	int capacity;
	Object *objects;
	enum{INCREMENT = 100,INITSIZE = 100};
	void resize(int incre){
		Object *newBase = new Object[capacity + incre];
		for(int i = 0 ; i < theSize; i++)
			newBase[i] = objects[i];
		delete []objects;
		objects = newBase;
		capacity += incre;
	}
public:
	MyStack(){
		theSize = 0;
		capacity = INITSIZE;
		objects = new Object[INITSIZE];
	}
	MyStack(const MyStack& rhs){
		if(this != &rhs){
			MyStack::operator=(rhs);
		}
		return *this;
	}
	~MyStack(){
		delete []objects;
		objects = NULL;
	}
	const MyStack& operator=(const MyStack& rhs){
		if(rhs.theSize > capacity)
			resize(INCREMENT);
		theSize = rhs.theSize;
		delete []objects;
		objects = new Object[rhs.theSize];
		for(int i = 0; i < rhs.theSize; i++)
			objects[i] = rhs.objects[i];
	}
	int size(){
		return theSize;
	}
	void push(const Object& obj){
		if(theSize == capacity)
			resize(INCREMENT);
		objects[theSize++] = obj;
	}
	const Object& pop(){
		return objects[--theSize];
	}
	Object top(){
		return objects[--theSize];
		theSize++;
	}
};
#endif